<template>
  <!-- Form -->
  <el-button text @click="dialogFormVisible = true"> open a Form nested Dialog </el-button>

  <el-dialog v-model="dialogFormVisible" title="Shipping address">
    <el-form :model="formdata">
      <el-form-item label="Promotion name" :label-width="formLabelWidth">
        <TestAutocomplete :value="formdata.value"></TestAutocomplete>
      </el-form-item>
      <el-form-item label="Promotion name" :label-width="formLabelWidth">
        <el-input v-model="formdata.link" autocomplete="off" />
      </el-form-item>
      <el-form-item label="Promotion name" :label-width="formLabelWidth">
        <el-input v-model="formdata.address" autocomplete="off" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogFormVisible = false">Cancel</el-button>
        <el-button type="primary" @click="dialogFormVisible = false"> Confirm </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { useTestStore } from './test.js'

import TestAutocomplete from './TestAutocomplete.vue'

const testStore = useTestStore()
const { dialogFormVisible, formdata } = storeToRefs(testStore)

const formLabelWidth = '140px'
</script>
<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
